package com.example.reggie.factory_pattem;

public class FactoryPatten {
    /**
     * 定义一个方法 返回创建对象
     */
    public static Computer createComputer(String info) {
        switch (info) {
            case "huawei":
                Computer c = new Huawei();
                c.setName("huawei");
                c.setPrice(5999);
                return c;
            case "mac":
                Computer mac = new Mac();
                mac.setName("mac");
                mac.setPrice(9999);
                return mac;
            default:
                return null;
        }
    }

}
